package com.example.cwfdemo.utils;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;


public class HttpResponseUtils {

    private static String charset = "UTF-8";

    public static void writeJSONResponse(HttpServletResponse response, String jsonResponse) throws Exception {
        response.setHeader("Content-Type", "text/html; charset=UTF-8");
        ServletOutputStream sos = response.getOutputStream();
        sos.write(jsonResponse.getBytes(charset));
        sos.flush();
        sos.close();
    }

    public static void redirectUrl(HttpServletResponse response, String url) throws Exception {
        response.setHeader("Content-Type", "text/html; charset=UTF-8");
        response.sendRedirect(url);
    }

}
